Ext.BLANK_IMAGE_URL = "./js/ext/resources/images/default/s.gif";
Ext.onReady(function() {

	var _panel = new Ext.Panel({
		title : "登录界面",
		width : 300,
		height : 170,
		frame : true,
		items : [{
					xtype : 'form',
					labelWidth : 70,
					buttonAlign:'center',
					items : [{
								id:"username",
								xtype : 'textfield',
								fieldLabel : "用户名",
								width : 150,
								name : 'admin.aName',
								emptyText : "请输入您的用户名",
								allowBlank : false,
								blankText : "请务必填写用户名"
							}, {
								id:"password",
								xtype : 'textfield',
								fieldLabel : "密码",
								width : 150,
								name : 'admin.nPassword',
								inputType : 'password',

								emptyText : "请输入您的密码",
								allowBlank : false,
								blankText : "请务必填写密码"
							}, {
								// xtype:'panel',
								//title:'haha',
								//height:70,
								layout : 'column',
								items : [{
											columnWidth : .5,
											//xtype : 'panel',
											layout : 'form',
											items : [{
														id:'validationCode',
														//anchor:"100%",
														xtype : 'textfield',
														fieldLabel : "  验证码",
														inputType : 'image'
													}]
										
										},{
											columnWidth : .3,
											//xtype : 'panel',
											//layout : 'form',
											//bodyStyle:"padding:5px",
											items : [{
												//labelWidth : 10,
														xtype : 'textfield',
														//fieldLabel : '验证码',
														width:100,
														emptyText : "请输入验证码",
														allowBlank : false,
														blankText : "请务必输入正确的验证码"
													}]
										}]
							}],
					buttons : [{
								id : "login",
								text : "登录"
							}, {
								id : "reset",
								text : "重置"
								//type : "reset"
								
							},{
								id:"getValidationCode",
								text:"刷新验证码",
								handler:function(){
									Ext.getCmp("validationCode").getEl().dom.src="http://localhost:8080/itnetwork/js/master/images/icon/lightbulb.gif";
								}
								}]
			/*	listeners:{
						"show":function(){
							//alert("show");
							Ext.getCmp("validationCode").getEl().dom.src="http://localhost:8080/itnetwork/js/master/images/icon/lightbulb.gif";
							}
						}*/
																												
												}]
	});

	Ext.getCmp("login").addListener("click", function() {
		// alert(this.ownerCt.ownerCt.title);
		var baseform = this.ownerCt.getForm()
		if (baseform.isValid()) {
			// alert("valid pass");
			baseform.submit({
						waitTitle : "请稍后",
						waitMsg : "正在提交数据..",
						url : "http://localhost:8080/itnetwork/login.action",
						method : 'GET',
						success : function(form, action) { // 提交成功钩子函数
							Ext.example.msg("提交成功", "提交登陆信息成功……",
									"msg-box-success");
							// Ext.Msg.alert("成功响应");
							// Ext.Msg.alert("响应成功");
							// Ext.Msg.alert(action.result.success);
							window.location = 'default.html';
						},
						failure : function(form, action) {
							Ext.Msg.alert("响应失败");
						}

					});
		} else {
			alert("valid not pass")
		};
	});
	Ext.getCmp("reset").addListener("click", function() {
				this.ownerCt.getForm().reset();
			});
	_panel.applyToMarkup(Ext.DomHelper.append(Ext.getBody(), {
				tag : "div",
				cls : "contain",
				cn : [{
							tag : "div",
							cls : "center"
						}]
			}, true).child("div"));
	Ext.getCmp("validationCode").getEl().dom.src="http://localhost:8080/itnetwork/js/master/images/icon/lightbulb.gif";
})